<template>
	<view class="mine-back">
		<view>
			<top-heigth></top-heigth>
			<uv-navbar :fixed="false" bg-color="rgba(0,0,0,0)" title="我的" :safeAreaInsetTop="false">
				<template v-slot:right></template>
				<template v-slot:left>
					<view class="uv-nav-slot"></view>
				</template>
			</uv-navbar>
		</view>
		
		<view class="content-box" v-if="detail">
			<view class="top-head-box">
				<view class="head-box">
					<view class="head">
						<!-- <image src="/static/image/mine-head.png" mode=""></image> -->
						<image :src="detail && detail.staffCover ? detail.staffCover : '/static/image/mine-head.png'" mode="aspectFill"></image>
					</view>
					
					<view>
						{{detail.staffName ? detail.staffName : '未设置昵称'}}
						<text v-if="detail.isAuthentication" style="font-size: 24rpx; color: blue;">(已实名)</text>
						
						<view style="font-size: 24rpx; color: #666666; line-height: 40rpx;">
							{{detail.tAppSupplierVo && detail.tAppSupplierVo.billType == 1 ? "分账商家" : "月租商家" }}
						</view>
						<view style="font-size: 24rpx; color: #666666;" v-if="detail.tAppSupplierVo && detail.tAppSupplierVo.billType == 2">
							到期时间：{{detail.billDateEnd ? detail.billDateEnd : "请续费"}}
						</view>
						
					</view>
					
				</view>
				<view class="head-right" @click="goPersonal()">
					<image src="/static/image/mine-img.png"></image>
					<span>个人中心</span>
				</view>
			</view>
			<view class="content-box mine-nav">
				<view class="mine-nav-list">
					<view class="list" @click="toshiming()">
						<image v-if="detail.isAuthentication == 1" src="/static/image/mine-icon1.png"></image>
						<image v-else src="/static/image/mine-icon11.png"></image>
						<view>实名认证</view>
					</view>
					<view class="list"> <!--  -->
						<image v-if="detail.bodyImg" src="/static/image/mine-icon2.png"></image>
						<image v-else src="/static/image/mine-icon22.png"></image>
						<view>健康证</view>
					</view>
					<view class="list"> <!--  -->
						<image v-if="detail.certificationImgFace" src="/static/image/icon3.png"></image>
						<image v-else src="/static/image/mine-icon33.png"></image>
						<view>从业资质</view>
					</view>
				</view>
			</view>
			
			
			<view class="content-box mine-font">
				<view>
					<view class="list" @click="goBusiness()" v-if="!detail.tAppSupplierVo">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list1.png"></image>
							<span>所属{{!isShenhe ? "商家" : "门店"}}</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" v-else @click="showShopPic">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list1.png"></image>
							<span>所属{{!isShenhe ? "商家" : "门店"}}</span>
						</view>
						<view style="font-weight: bold;">{{detail.tAppSupplierVo.supplierName}}</view>
					</view>
					<view class="list" @click="goContract()">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list2.png"></image>
							<span>合同管理</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
				</view>
			</view>
			
			<view class="content-box mine-font">
				<view>
					<view class="list" @click="goPersonal2()">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list3.png"></image>
							<span>个人信息</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" @click="goService()">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list4.png"></image>
							<span>服务项目</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" >
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list5.png"></image>
							<span>接单时段</span>
							<view class="list-r" @click="goTime()">
								<view class="list-r-font">
									<span style="margin-right: 16rpx;">{{detail.tAppStaffTimeConfigVo.startTime}}--{{detail.tAppStaffTimeConfigVo.endTime}}</span> &nbsp;&nbsp;&nbsp;
									<!-- (7天/周或周一周二） -->
									<span v-if="detail.tAppStaffTimeConfigVo.monday == 1">周一</span>
									<span v-if="detail.tAppStaffTimeConfigVo.tuesday == 1">周二</span>
									<span v-if="detail.tAppStaffTimeConfigVo.wednesday == 1">周三</span>
									<span v-if="detail.tAppStaffTimeConfigVo.thursday == 1">周四</span>
									<span v-if="detail.tAppStaffTimeConfigVo.friday == 1">周五</span>
									<span v-if="detail.tAppStaffTimeConfigVo.staturday == 1">周六</span>
									<span v-if="detail.tAppStaffTimeConfigVo.sunday == 1">周日</span>
								</view>
								
							</view>
						</view>
						
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" @click="toLocation" v-if="!isShenhe">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list66.png"></image>
							<span>接单位置</span>
							<view class="font-hui">
								{{detail.staffAddress}}
							</view>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" @click="goLaHei()">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list6.png"></image>
							<span>拉黑列表</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
				</view>
			</view>
			
			<view class="content-box mine-font">
				<view>
					<view class="list" @click="goCash()">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list7.png"></image>
							<span>收入提现</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" @click="goInvite()">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list8.png"></image>
							<span>邀请记录</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" @click="goRwm()" v-if="!isShenhe">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list9.png"></image>
							<span>推广分享</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" @click="goText()">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list8.png"></image>
							<span>服务协议</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" @click="goText3()">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list8.png"></image>
							<span>隐私政策</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<view class="list" @click="goText4()" v-if="detail && detail.tAppSupplierVo && detail.tAppSupplierVo.billType == 2">
						<view class="list-l">
							<image class="icon" src="/static/image/mine-list8.png"></image>
							<span>到期时间</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view>
					<!-- <view class="list" @click="goText4()" v-if="!isShenhe">
						<view class="list-l">
							<image class="icon" src="/static/image/lvyin.png"></image>
							<span>一键录音</span>
						</view>
						<image class="go" src="/static/image/more.png"></image>
					</view> -->
				</view>
			</view>
			
		</view>
		<view style="margin: 0 50rpx;">
			<view class="logout-but" @click="logout">退出登录</view>
		</view>
		<view style="margin: 0 50rpx;">
			<view class="logout-but" @click="unsign">注销账号</view>
		</view>
		<view style="height:50rpx;"></view>
	</view>
</template>

<script>
	import TopHeigth from '@/components/TopHeigth.vue'
	
	
	export default {
		data() {
			return {
				backTitle:"我的",
				userInfo: uni.getStorageSync('userInfo'),
				location: uni.getStorageSync('location'),
				detail: null,
				name:'',
				isShenhe: 1
			}
		},
		components: { TopHeigth },
		onShow() {
			this.getDetail()
			uni.$u.http.post('/api/shop/v1_0/linyue/version',{}).then((res) => {
				this.isShenhe = !res.data
			})
			
		},
		methods: {
			toshiming(){
				uni.navigateTo({
					url: "/pages/index/personal",
				});
			},
			showShopPic(){
				uni.navigateTo({
					url: '/pages/mine/shopinfo'
				});
			},
			goText: function(){
				uni.navigateTo({
					url: '/pages/login/text'
				});
			},
			goText3: function(){
				uni.navigateTo({
					url: '/pages/login/text3'
				});
			},
			goText4: function(){
				uni.navigateTo({
					url: '/pages/mine/cash'
				});
			},
			unsign(){
				uni.showModal({
					title: '提示',
					content: '确定注销吗?',
					success: (res) => {
						if (res.confirm) {
							uni.setStorageSync('userInfo', null);
							uni.redirectTo({
								url: "/pages/login/index"
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			logout(){
				uni.showModal({
					title: '提示',
					content: '确定退出吗?',
					success: (res) => {
						if (res.confirm) {
							uni.setStorageSync('userInfo', null);
							uni.redirectTo({
								url: "/pages/login/index"
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			getDetail(){ // 技师详情
				uni.$u.http.post('/api/shop/v1_0/tAppStaffRCA/turnTAppStaffInfo',{
					id:this.userInfo.id,
				}).then((res) => {
					this.detail = res.data
					// 判断是否默认定位
					if(this.location && this.location.latitude && this.location.formattedAddress && !this.detail.staffAddress){
						// 有定位信息但是用户没有设置接单定位
						uni.$u.http.post('/api/shop/v1_0/tAppStaffRCA/updateTAppStaff',{
							id:this.userInfo.id,
							version: this.detail.version,
							staffAddress: this.location.formattedAddress,
							staffLat: this.location.latitude,
							staffLng: this.location.longitude,
						}).then((res) => {
							this.detail.staffAddress = this.location.formattedAddress
						})
					}
				})
			},
			goJoin(){ // 合作加盟
				uni.navigateTo({
					url: "/pages/mine/join"
				})
			},
			goJoin2(){ // 招聘 合作
				uni.navigateTo({
					url: "/pages/mine/join2"
				})
			},
			goBusiness(){ // 所属商家
				uni.navigateTo({
					url: "/pages/mine/business?supplierId=" + this.detail.supplierId + "&id=" + this.detail.id + "&version=" + this.detail.version
				})
			},
			goContract(){ // 合同管理
				uni.navigateTo({
					url: "/pages/index/contract"
				})
			}, 
			goPersonal2(){//个人信息
				uni.navigateTo({
					url: "/pages/index/personal"
				})
			},
			goPersonal(){ //个人中心
				uni.navigateTo({
					url: "/pages/mine/personal"
				})
			},
			goLaHei(){ //拉黑列表
				uni.navigateTo({
					url: "/pages/mine/laHei"
				})
			},
			goCash(){ //收入提现
				uni.navigateTo({
					url: "/pages/index/cash"
				})
			},
			goInvite(){ //邀请记录
				uni.navigateTo({
					url: "/pages/mine/invite"
				})
			},
			goRwm(){ //推广分享
				uni.navigateTo({
					url: "/pages/mine/rwm"
				})
			},
			goService(){
				uni.navigateTo({
					url: "/pages/mine/service"
				})
			},
			goTime(){
				uni.navigateTo({
					url: "/pages/index/time"
				})
			},
			toLocation(){
				uni.navigateTo({
					url: "/pages/index/place"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@mixin flex($direction: row) {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: $direction;
	}
	.uv-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: #dadbde;
		padding: 3px 7px;
		opacity: 0.8;
	}
	.top-head-box{
		@include flex;
		align-items: center;
		justify-content:space-between;
		height: 200rpx;
		margin-top: 10rpx
		
	}
	.head-box{
		@include flex;
		align-items: center;
		justify-content:flex-start;
	}
	.head-box .head{
		width:116rpx;
		height: 116rpx;
		border-radius: 100rpx;
		overflow: hidden;
		text-align: center;
		box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.2);
		
		margin-right: 24rpx;
		background: #fff;
	}
	.head{
		border: 4rpx solid #fff;
	}
	.head image{
		width:116rpx;
		height: 116rpx;
	}
	
	.head-right{
		@include flex;
		align-items: center;
		justify-content:flex-start;
		image{
			width:32rpx;
			height:32rpx;
			margin-right: 8rpx;
		}
	}
	.mine-back{
		background: url("/static/image/back2.png") no-repeat;
		background-size: 100% auto;
		
	}
	.mine-nav{
		background: #fff;
		border-radius: 16rpx;
		box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.1);
		font-size: 24rpx;
		padding-top: 20rpx;
		padding-bottom:20rpx ;
		
		.mine-nav-list{
			@include flex;
			align-items: center;
			justify-content:space-between;
			.list{
				text-align: center;
				width: 20%;
				image{
					width: 93rpx;
					height: 93rpx;
				}
			}
			
		}
	}
	.mine-font{
		background: #fff;
		border-radius: 16rpx;
		box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.1);
		font-size: 24rpx;
		margin-top: 24rpx;
		
		.list{
			@include flex;
			align-items: center;
			justify-content:space-between;
			padding:28rpx 0;
			border-bottom: 2rpx solid #eee;
			.go{
				width: 32rpx;
				height: 32rpx;
			}
			.list-l{
				@include flex;
				align-items: center;
				justify-content:flex-start;
				.icon{
					width: 40rpx;
					height: 40rpx;
				}
				span{
					margin-left: 6rpx;
					min-width: 130rpx;
				}
				.font-hui{
					margin-left: 26rpx;
				}
			}
		}
		.list:last-child{
			border-bottom:none;
		}
	}
	.nc{
		@include flex;
		align-items: center;
		justify-content:flex-start;
	}
</style>
